import dynamic from 'dva/dynamic';
import {auth} from "../config/config";

// wrapper of dynamic
const dynamicWrapper = (app, models, component) => dynamic({
  app,
  models: () => models.map(item => import(`../models/${item}.js`)),
  component,
});

// get user and main layout
export const getUserLayout = app => dynamicWrapper(app, [], () => import('../routes/layouts/UserLayout'));
export const getMainLayout = app => dynamicWrapper(app, ['user'], () => import('../routes/layouts/MainLayout'));

// get user nav data
export const getUserNavList = app => [{
  name: '登录',
  path: '/users_login',
  component: dynamicWrapper(app, ['user'], () => import('../routes/user/Login')),
}, {
  name: '注册',
  path: '/users_register',
  component: dynamicWrapper(app, ['user'], () => import('../routes/user/Register')),
}, {
  name: '注册结果',
  path: '/register_result',
  component: dynamicWrapper(app, ['user'], () => import('../routes/user/RegisterResult')),
}];

// get main nav data
export const getMainNavList = app => [{
  id: 1,
  pid: 0,
  name: 'Dashboard',
  icon: 'dashboard',
  path: '/dashboard',
  component: dynamicWrapper(app, ['dashboard'], () => import('../routes/dashboard/Index')),
  authId: auth.dashboard.id,
}, {
  id: 2,
  pid: 0,
  name: '项目管理',
  icon: 'folder',
  path: '',
  component: null,
  authId: auth.projectManagement.id,
}, {
  id: 3,
  pid: 0,
  name: '会员管理',
  icon: 'user',
  path: '/customers',
  component: dynamicWrapper(app, ['customer'], () => import('../routes/customer/Index')),
  authId: auth.customerManagement.id,
}, {
  id: 4,
  pid: 0,
  name: '资方管理',
  icon: 'dollar',
  path: '/fundings',
  component: dynamicWrapper(app, ['funding'], () => import('../routes/funding/Index')),
  authId: auth.favList.id,
}, {
  id: 6,
  pid: 0,
  name: '服务方管理',
  icon: 'global',
  path: '/services',
  component: dynamicWrapper(app, ['service'], () => import('../routes/service/Index')),
  authId: auth.favList.id,
}, {
  id: 5,
  pid: 0,
  name: '内容管理',
  icon: 'profile',
  path: '',
  component: null,
  authId: auth.postManagement.id,
}, {
  id: 10,
  pid: 0,
  name: '系统设置',
  icon: 'setting',
  path: '',
  component: null,
  authId: auth.systemSetting.id,
}, {
  id: 201,
  pid: 2,
  name: '项目分类',
  icon: '',
  path: '/project_cats',
  component: dynamicWrapper(app, ['project_cat'], () => import('../routes/project_cat/Index')),
  authId: auth.projectCat.id,
}, {
  id: 202,
  pid: 2,
  name: '项目管理',
  icon: '',
  path: '/projects',
  component: dynamicWrapper(app, ['project_cat', 'project'], () => import('../routes/project/Index')),
  authId: auth.project.id,
}, {
  id: 301,
  pid: 3,
  name: '编辑会员',
  icon: '',
  path: '/customer/:id/edit',
  component: dynamicWrapper(app, ['customer'], () => import('../routes/customer/CustomerCU')),
  visible: false,
  authId: auth.postU.id
}, {
  id: 303,
  pid: 3,
  name: '新增会员',
  icon: '',
  path: '/customer/new',
  component: dynamicWrapper(app, ['customer'], () => import('../routes/customer/CustomerCU')),
  visible: false,
  authId: auth.postC.id
}, {
  id: 302,
  pid: 3,
  name: '查看会员',
  icon: '',
  path: '/customer/:id',
  component: null,
  visible: false,
  authId: auth.postR.id
}, {
  id: 401,
  pid: 4,
  name: '编辑资方',
  icon: '',
  path: '/funding/:id/edit',
  component: dynamicWrapper(app, ['funding'], () => import('../routes/funding/FundingCU')),
  visible: false,
  authId: auth.postU.id
}, {
  id: 403,
  pid: 4,
  name: '新增资方',
  icon: '',
  path: '/funding/new',
  component: dynamicWrapper(app, ['funding'], () => import('../routes/funding/FundingCU')),
  visible: false,
  authId: auth.postC.id
}, {
  id: 402,
  pid: 4,
  name: '查看资方',
  icon: '',
  path: '/funding/:id',
  component: null,
  visible: false,
  authId: auth.postR.id
}, {
  id: 601,
  pid: 6,
  name: '编辑服务方',
  icon: '',
  path: '/service/:id/edit',
  component: dynamicWrapper(app, ['service'], () => import('../routes/service/ServiceCU')),
  visible: false,
  authId: auth.postU.id
}, {
  id: 603,
  pid: 6,
  name: '新增服务方',
  icon: '',
  path: '/service/new',
  component: dynamicWrapper(app, ['service'], () => import('../routes/service/ServiceCU')),
  visible: false,
  authId: auth.postC.id
}, {
  id: 602,
  pid: 6,
  name: '查看服务方',
  icon: '',
  path: '/service/:id',
  component: null,
  visible: false,
  authId: auth.postR.id
}, {
  id: 501,
  pid: 5,
  name: '内容分类',
  icon: '',
  path: '/post_cats',
  component: dynamicWrapper(app, ['post_cat'], () => import('../routes/post_cat/Index')),
  authId: auth.postCat.id,
}, {
  id: 502,
  pid: 5,
  name: '内容管理',
  icon: '',
  path: '/posts',
  component: dynamicWrapper(app, ['post_cat', 'post'], () => import('../routes/post/Index')),
  authId: auth.post.id
}, {
  id: 1001,
  pid: 10,
  name: '用户管理',
  icon: '',
  path: '/users',
  component: dynamicWrapper(app, ['user'], () => import('../routes/user/Index')),
  authId: auth.customer.id
}, {
  id: 1002,
  pid: 10,
  name: '系统设置',
  icon: '',
  path: '/setting',
  component: dynamicWrapper(app, ['user'], () => import('../routes/test/Demo')),
  authId: auth.setting.id
}, {
  id: 20201,
  pid: 202,
  name: '编辑项目',
  icon: '',
  path: '/project/:id/edit',
  component: dynamicWrapper(app, ['project_cat', 'project'], () => import('../routes/project/ProjectCU')),
  visible: false,
  authId: auth.postU.id
}, {
  id: 20203,
  pid: 202,
  name: '新增项目',
  icon: '',
  path: '/project/new',
  component: dynamicWrapper(app, ['project_cat', 'project'], () => import('../routes/project/ProjectCU')),
  visible: false,
  authId: auth.postC.id
}, {
  id: 20202,
  pid: 202,
  name: '查看项目',
  icon: '',
  path: '/project/:id',
  component: dynamicWrapper(app, ['project'], () => import('../routes/project/ProjectDetail')),
  visible: false,
  authId: auth.postR.id
}, {
  id: 50201,
  pid: 502,
  name: '编辑内容',
  icon: '',
  path: '/post/:id/edit',
  component: dynamicWrapper(app, ['post_cat', 'post'], () => import('../routes/post/PostCU')),
  visible: false,
  authId: auth.postU.id
}, {
  id: 50203,
  pid: 502,
  name: '新增内容',
  icon: '',
  path: '/post/new',
  component: dynamicWrapper(app, ['post_cat', 'post'], () => import('../routes/post/PostCU')),
  visible: false,
  authId: auth.postC.id
}, {
  id: 50202,
  pid: 502,
  name: '查看内容',
  icon: '',
  path: '/post/:id',
  component: dynamicWrapper(app, ['post'], () => import('../routes/post/PostDetail')),
  visible: false,
  authId: auth.postR.id
}, {
  id: 100101,
  pid: 1001,
  name: '编辑用户',
  icon: '',
  path: '/user/:id/edit',
  component: dynamicWrapper(app, ['user'], () => import('../routes/user/UserCU')),
  visible: false,
  authId: auth.postU.id
}, {
  id: 100103,
  pid: 1001,
  name: '新增用户',
  icon: '',
  path: '/user/new',
  component: dynamicWrapper(app, ['user'], () => import('../routes/user/UserCU')),
  visible: false,
  authId: auth.postC.id
}, {
  id: 100102,
  pid: 1001,
  name: '查看用户',
  icon: '',
  path: '/user/:id',
  component: dynamicWrapper(app, ['user'], () => import('../routes/user/UserDetail')),
  visible: false,
  authId: auth.postR.id
}/*, {
  id: 301,
  pid: 3,
  name: '栏目管理',
  icon: '',
  path: '/post/post_cat_list',
  component: dynamicWrapper(app, ['post_cat'], () => import('../routes/post/ContentCatList')),
}, {
	id: 302,
	pid: 3,
	name: '模型管理',
	icon: '',
	path: '/post/model_list',
	component: dynamicWrapper(app, ['post/Model'], () => import('../routes/post/ModelList')),
}, {
	id: 303,
	pid: 3,
	name: '文章管理',
	icon: '',
	path: '/post/post_list',
	component: dynamicWrapper(app, ['post/Post'], () => import('../routes/post/PostList')),
}, {
	id: 304,
	pid: 3,
	name: '图片管理',
	icon: '',
	path: '/post/image_list',
	component: dynamicWrapper(app, ['post/Image'], () => import('../routes/post/ImageList')),
}, {
  id: 1201,
  pid: 12,
  name: '基础表单',
  icon: '',
  path: '/form/basic_form',
  component: dynamicWrapper(app, ['form'], () => import('../routes/forms/BasicForm')),
}, {
  id: 1202,
  pid: 12,
  name: '高级表单',
  icon: '',
  path: '/form/advanced_form',
  component: dynamicWrapper(app, ['form'], () => import('../routes/forms/AdvancedForm')),
}, {
  id: 1301,
  pid: 13,
  name: '查询表格',
  icon: '',
  path: '/list/table_list',
  component: dynamicWrapper(app, ['rule'], () => import('../routes/list/TableList')),
}, {
  id: 1302,
  pid: 13,
  name: '标准列表',
  icon: '',
  path: '/list/basic_list',
  component: dynamicWrapper(app, ['list'], () => import('../routes/list/BasicList')),
}, {
  id: 1303,
  pid: 13,
  name: '卡片列表',
  icon: '',
  path: '/list/card_list',
  component: dynamicWrapper(app, ['list'], () => import('../routes/list/CardList')),
}, {
  id: 1304,
  pid: 13,
  name: '搜索列表（项目）',
  icon: '',
  path: '/list/cover_card_list',
  component: dynamicWrapper(app, ['list'], () => import('../routes/list/CoverCardList')),
}, {
  id: 1305,
  pid: 13,
  name: '搜索列表（应用）',
  icon: '',
  path: '/list/filter_card_list',
  component: dynamicWrapper(app, ['list'], () => import('../routes/list/FilterCardList')),
}, {
  id: 1306,
  pid: 13,
  name: '搜索列表（文章）',
  icon: '',
  path: '/list/search',
  component: dynamicWrapper(app, ['list'], () => import('../routes/list/SearchList')),
}*/];
